#include <stdio.h>
#include "my_jpeg.h"  //引用自定义的接口

//arm-linux-gcc main.c my_jpeg.c -o main -I /home/china/jpeg_lib/include -L /home/china/jpeg_lib/lib -ljpeg


int lcdfd;//全局变量
int *lcdbuf; //全局变量

//封装LCD屏幕初始化函数
int lcd_init()
{
    //打开LCD屏幕文件
    lcdfd = open("/dev/fb0",O_RDWR);
    if( lcdfd == -1)
    {
        printf("open 1.txt failed\n");
        return -1;
    }

    //内存映射
    lcdbuf = mmap(NULL,800*480*4,PROT_WRITE | PROT_READ,MAP_SHARED,lcdfd,0);
    if( lcdbuf == MAP_FAILED)
    {
        printf("mmap failed\n");
        return -1;
    }
}

int main()
{
    //lcd屏幕初始化
    lcd_init();

    //显示jpeg图片
    read_JPEG_file("1.jpg",lcdbuf);


    close(lcdfd);//关闭LCD文件
    munmap(lcdbuf, 800*480*4);//释放堆空间
}